import allure
from page_object.roncoo_login import RoncooLogin
from page_element.el_user import *
import logging
from utils.timer import sleep


class Recnoo_search(RoncooLogin):
    """首页搜索商品后退出登录"""

    def recnoo_yhsearch(self, info, expected, casename):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击用户管理"):
            self.click(recnoo.recnoo_yggl)
            sleep(2)
        with allure.step(f"点击用户信息"):
            self.click(recnoo.recnoo_yyxx)
        with allure.step(f"输入用户编号"):
            self.send_keys(recnoo.recnoo_ssk, info)
        with allure.step(f"点击查询按钮"):
            self.click(recnoo.recnoo_ssan)
            sleep(2)
        with allure.step(f"断言"):
            if '正向用例' == casename:
                dy = self.text(recnoo.recnoo_dy)
                assert expected == dy
            else:
                dy = self.text(recnoo.recnoo_dy2)
                assert expected == dy
